import React, { FC,useState,useEffect,useImperativeHandle,forwardRef } from 'react';
import { Form,Button,Input,TreeSelect,message } from 'antd';
import { getDirectoryInfoInfo,getDirectoryTreeSelect,updateDirectoryInfo } from '../../../apis/backhub/directory';

interface Directory {
  id: number;
  name: string;
  parentId:number;
  directoryPath:string;
  createDateTime?:string;
  children?:Directory[]
}
const DirectoryEditForm = (props:{ directoryId:number,onSuccess?:any },ref) => {
	const [viewDirectoryInfo,setViewDirectoryInfo] = useState<Directory>();
	useImperativeHandle(ref,() => ({
		  func 
		})
	);
	const func=()=>{
		handleView()
	}
	useEffect(() => {
	  handleView()
	}, []);
	
	const handleView = async() => {
		const res = await getDirectoryInfoInfo(props.directoryId)
		if(res.status&&res.data.success){
			setViewDirectoryInfo(res.data.data as Directory)
		}else{
			message.error(res.data.message)
		}
	};
	
	return (
		<div className="upload-container">
			<Form
			  layout="vertical"
			>
			  <Form.Item
				label="目录名称"
				name="name"
			  >
				<text >{viewDirectoryInfo?.name}</text>
			  </Form.Item>
			  <Form.Item
					label="目录路径"
					name="name"
				>
					<text >{viewDirectoryInfo?.directoryPath}</text>
			  </Form.Item>
			</Form>
		</div>
	);
};

export default forwardRef(DirectoryEditForm);
